<?php

/**
 * @author christian
 * @copyright 2011
 *  
 */

 //establecer una variable conratafisica $_LOCALHOST
$ruta=$_SERVER['DOCUMENT_ROOT']."/viventura"."/MDTour";
include_once("$ruta/star.php");
//include_once("$ruta/MDTourGeneral/MDPasajeros/CPaxEdit.php");
//include_once("$rut/conf/CConfig.php");

//Campos de control
if (!isset($_POST['action'])) {$_POST['action'] = "NULL"; }
$action=$_POST['action'];


if (!isset($_GET['action_d'])) {$_GET['action_d'] = "NULL";}; 
$action_d=$_GET['action_d'];

if (!isset($_GET['idTourPax'])){$_GET['idTourPax'] = "NULL"; }
$idTourPax = $_GET['idTourPax'];

//Campos de registro
if (!isset($_POST['idPax'])){$_POST['idPax'] = "NULL"; }
if (!isset($_POST['NumDocPax'])){$_POST['NumDocPax'] = "NULL";;}	
if (!isset($_POST['GenPax'])){$_POST['GenPax']= "NULL";;}
if (!isset($_POST['PassPax'])){$_POST['PassPax']= "NULL";;} 	 	
if (!isset($_POST['FirstNamPax'])){$_POST['FirstNamPax']= "NULL";;} 	
if (!isset($_POST['LastNamPax'])){$_POST['LastNamPax']= "NULL";;} 	
if (!isset($_POST['NatPax'])){$_POST['NatPax']= "NULL";;}	
if (!isset($_POST['BorDatPax'])){$_POST['BorDatPax']= "NULL";;} 	 	
if (!isset($_POST['PhoPax'])){$_POST['PhoPax']= "NULL";;} 	 	
if (!isset($_POST['MovPax'])){$_POST['MovPax']= "NULL";;} 	 	
if (!isset($_POST['FaxPax'])){$_POST['FaxPax']= "NULL";;} 	 	
if (!isset($_POST['PosCodPax'])){$_POST['PosCodPax']= "NULL";;} 	 	
if (!isset($_POST['MailPax'])){$_POST['MailPax']= "NULL";;} 	 	
if (!isset($_POST['VegFooPax'])){$_POST['VegFooPax']= "NULL";;} 	 	
if (!isset($_POST['SmkPax'])){$_POST['SmkPax']= "NULL";;} 	
if (!isset($_POST['StuPax'])){$_POST['StuPax']= "NULL";;}



$idPax=$_POST['idPax'];
$NumDocPax=$_POST['NumDocPax'];	
$GenPax=$_POST['GenPax'];
$PassPax =$_POST['PassPax']; 	 	
$FirstNamPax =$_POST['FirstNamPax']; 	
$LastNamPax =$_POST['LastNamPax']; 	
$NatPax =$_POST['NatPax']; 	 	
$BorDatPax =$_POST['BorDatPax']; 	 	
$PhoPax =$_POST['PhoPax']; 	 	
$MovPax =$_POST['MovPax']; 	 	
$FaxPax =$_POST['FaxPax']; 	 	
$PosCodPax =$_POST['PosCodPax']; 	 	
$MailPax =$_POST['MailPax']; 	 	
$VegFooPax =$_POST['VegFooPax']; 	 	
$SmkPax =$_POST['SmkPax']; 	
$StuPax =$_POST['StuPax'];

$idPax=$_POST['idPax'];




if($action==1){
 $query = "update pasajero NumDocPax='$NumDocPax',GenPax='$GenPax',PassPax='$PassPax',FirstNamPax='$FirstNamPax',LastNamPax='$LastNamPax',NatPax='$NatPax',BorDatPax='$BorDatPax',PhoPax='$PhoPax',MovPax='$MovPax',FaxPax='$FaxPax',PosCodPax='$PosCodPax',MailPax='$MailPax',VegFooPax='$VegFoodPax',SmkPax='$SmkPax',StuPax='$StuPax' where idPax='$idPax'";
 
 
 //idPax,NumDocPax,GenPax,PassPax,FirstNamPax,LastNamPax,NatPax,BorDatPax,PhoPax,MovPax,FaxPax,PosCodPax,MailPax,VegFooPax,SmkPax,StuPax
        CModelo::getInstance()->insertData($query);
        
        echo "<script> parent.location.href = '/viventura/MDTour/MDTourGeneral/MDPasajeros/MDPasajeros.php?codigo=2923' </script>";
        
        }
        
elseif($action_d==1){
    if (!isset($_GET['idTour'])){$_GET['idTour']= "NULL";;}
    $idTour=$_GET['idTour'];    
    
    $query = "DELETE FROM tour_has_pasajero where idTourPax = $idTourPax";
    CModelo::getInstance()->insertData($query);
    echo "<script> parent.location.href = 'MDPasajeros.php?codigo=$idTour' </script>";
     
    
}

else{
    
    $idTour=$_POST['idTour'];
    
    $insertar= "insert into pasajero (idPax,NumDocPax,GenPax,PassPax,FirstNamPax,LastNamPax,NatPax,BorDatPax,PhoPax,MovPax,FaxPax,PosCodPax,MailPax,VegFooPax,SmkPax,StuPax) 
            values (NULL,'$NumDocPax','$GenPax','$PassPax','$FirstNamPax','$LastNamPax','$NatPax','$BorDatPax','$PhoPax','$MovPax','$FaxPax','$PosCodPax','$MailPax','$VegFooPax','$SmkPax','$StuPax')";
    //echo $insertar;
    $idPax = CModelo::getInstance()->insertData($insertar);
    
    $query= "insert into tour_has_pasajero (idTourPax,tour_idTour,pasajero_idPax) values ('NULL',$idTour,$idPax)";
    
    //echo $query;
    $idTourPax = CModelo::getInstance()->insertData($query);
     
    echo "<script> parent.location.href = '/viventura/MDTour/MDTourGeneral/MDPasajeros/CPaxEdit.php?codigo=$idTour&action=0' </script>";
        
        
}


?>
